var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIBase"),
    s = t("CardDayItem"),
    c = t("GameEm"),
    p = cc._decorator,
    l = p.ccclass,
    d =
        (p.property,
        p.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.listData = [];
                e.allLevel = 0;
                e.lastCurLv = 0;
                e.canClick = !1;
                e.addZSCount = 0;
                return e;
            }
            e.prototype.onShowEnd = function () {
                EVUIEffView.on(EVUIEffView.checkCostUI, this.updateAllViewCost.bind(this), this);
                QAudio.play(QAudio.ui_popup);
                var t = [];
                switch (this.ui_data.dlgKind) {
                    case c.DataCard.moonCard:
                        if (!PayData.getCanMouth()) {
                            this.closeUI();
                            return;
                        }
                        this.allLevel = 30;
                        this.lastCurLv = PayData.getMouthCount();
                        console.log("UICardDlg ------------getMouthCount-- this.lastCurLv --- " + this.lastCurLv);
                        t = this.getCardMonthLastList(this.allLevel - this.lastCurLv, this.allLevel);
                        this._title.$Label.string = "月卡";
                        break;
                    case c.DataCard.weekCard:
                        if (!PayData.getCanWeak()) {
                            this.closeUI();
                            return;
                        }
                        this.allLevel = 7;
                        this.lastCurLv = PayData.getWeakCount();
                        console.log("UICardDlg -------------getWeakCount- this.lastCurLv --- " + this.lastCurLv);
                        t = this.getCardWeekLastList(this.allLevel - this.lastCurLv, this.allLevel);
                        this._title.$Label.string = "周卡";
                }
                console.log("UICardDlg ----------------- list", t);
                var e = t.length;
                this.listData = t;
                if (e > 0) {
                    this._ListGrop.$ListGroupCom.setPutGetNode(
                        function () {
                            return QLooperNode.getNode(QLooperNode.tag_CardDayItem);
                        },
                        function (t) {
                            QLooperNode.putNode(t);
                        }
                    );
                    this.updateView();
                }
                this.checkBtnCanClick();
            };
            e.prototype.checkBtnCanClick = function () {
                this.canClick = !1;
                console.log("UICardDlg ----------------- this.listData", this.listData);
                for (var t = 0; t < this.listData.length; t++)
                    this.listData[t].isOver && this.listData[t].canReward && (this.canClick = !0);
                console.log("UICardDlg ------------this.canClick----- ", this.canClick);
                this.setRender(this._getReward, this.canClick);
            };
            e.prototype.setRender = function (t, e) {
                for (var o = t.getComponentsInChildren(cc.RenderComponent), a = 0; a < o.length; a++)
                    CacheDataManager.setSpriteMat(o[a], e);
            };
            e.prototype.getCardMonthLastList = function (t, e) {
                var o = [],
                    a = CacheDataManager.getShopDataCof().shop,
                    i = (CacheDataManager.getShopDataCof().sheif_txt, (a[20161].products_daily + "").split("_")),
                    n = parseInt(i[1]);
                this.addZSCount = n;
                for (var r = PayData.getTodayMouth(), s = 0; s < e; s++) {
                    var c = !PayData.getMonthIsGetReward(s),
                        p = t == s && r;
                    o.push({id: s, count: n, old: s < t, isOver: p, canReward: c});
                }
                return o;
            };
            e.prototype.getCardWeekLastList = function (t, e) {
                var o = [],
                    a = CacheDataManager.getShopDataCof().shop,
                    i = (CacheDataManager.getShopDataCof().sheif_txt, (a[20162].products_daily + "").split("_")),
                    n = parseInt(i[1]);
                this.addZSCount = n;
                for (var r = PayData.getTodayWeek(), s = 0; s < e; s++) {
                    var c = !PayData.getWeekIsGetReward(s),
                        p = t == s && r;
                    o.push({id: s, count: n, old: s < t, isOver: p, canReward: c});
                }
                return o;
            };
            e.prototype.updateView = function () {
                var t = this.listData.length;
                this._ListGrop.$ListGroupCom.reSetBaseInfo(t, 0, this.setitemaction.bind(this));
            };
            e.prototype.updateAllViewCost = function () {
                var t;
                null === (t = this._ListGrop) || void 0 === t || t.$ListGroupCom.updateAllItem();
            };
            e.prototype.setitemaction = function (t, e, o) {
                o || (o = {});
                if (!o.com) {
                    o.com = e.getComponent(s.default);
                    o.id = t;
                }
                for (var a = null, i = 0; i < this.listData.length; i++)
                    if (this.listData[i].id == t) {
                        a = this.listData[i];
                        break;
                    }
                if (o.com && a) {
                    e.active = !0;
                    o.com.updateView(a, this.lastCurLv, this.allLevel);
                } else e.active = !1;
            };
            e.prototype._onGetRewardTouchEnd = function () {
                if (this.canClick) {
                    var t = this.ui_data.dlgKind,
                        e = this.lastCurLv,
                        o = this._getReward.convertToWorldSpaceAR(cc.Vec2.ZERO);
                    switch (t) {
                        case c.DataCard.moonCard:
                            var a = PayData.getMouthMaxCount(this.allLevel);
                            if (a < e) {
                                PayData.addPropData(c.RewardResKind.zhuanShi, this.addZSCount, o);
                                PayData.setMonthIsGetReward(a);
                            }
                            break;
                        case c.DataCard.weekCard:
                            var i = PayData.getWeekMaxCount(this.allLevel);
                            if (i < e) {
                                PayData.addPropData(c.RewardResKind.zhuanShi, this.addZSCount, o);
                                PayData.setWeekIsGetReward(i);
                                console.log("UICardDlg --------周--------- 完成");
                            }
                    }
                    this.closeUI();
                }
            };
            e.prototype.starGetRewawrd = function () {};
            e.prototype.onCloseStart = function () {
                EVUIEffView.emit(EVUIEffView.closeShop);
                QAudio.play(QAudio.ui_button);
                EVUIEffView.offTarget(this);
                this._ListGrop.$ListGroupCom.clearQLooperNode();
            };
            return n([l], e);
        })(r.default));
o.default = d;
